package com.lkd.handler;


import com.lkd.business.MsgHandler;
import com.lkd.business.Topic;
import com.lkd.config.TopicConfig;
import com.lkd.contract.OrderCheck;
import com.lkd.service.OrderService;
import com.lkd.utils.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Topic(TopicConfig.ORDER_CHECK_TOPIC)
public class OrderCheckHandler implements MsgHandler {

    @Autowired
    private OrderService orderService;

    @Override
    public void process(String jsonMsg) {

        log.info("接收到订单超时检查消息，jsonMsg={}",jsonMsg);
        if(StringUtils.isBlank(jsonMsg)){
            return ;
        }
        try {
            OrderCheck orderCheck = JsonUtil.getByJson(jsonMsg, OrderCheck.class);
//        检查订单状态
            orderService.orderCheck(orderCheck);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
